package com.zzyl.controller;


import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import com.zzyl.vo.NursingPlanVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级")
public class NursingLevelController {

    @Autowired
    private NursingLevelService nursingLevelService;

    @GetMapping("/listAll")
    @ApiOperation("获取护理等级列表")
    public ResponseResult<List<NursingLevelVo>>listAll(){

        List<NursingLevelVo> listAll = nursingLevelService.getAllNursingLevels();

        return ResponseResult.success(listAll);

    }


    @GetMapping("/{id}")
    @ApiOperation("根据id查询护理等级")
    public ResponseResult<NursingLevelVo> findById(@PathVariable Long id){

        NursingLevelVo nursingLevelVo = nursingLevelService.selectById(id);

        return ResponseResult.success(nursingLevelVo);
    }


    @GetMapping("/listByPage")
    @ApiOperation("分页查询护理等级")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", required = true, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "护理计划名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态", required = false, dataType = "int", paramType = "query")

    })
    public ResponseResult<List<NursingLevelVo>> listByPage(Integer pageNum, Integer pageSize, String name, Integer status){

        PageResponse<NursingLevelVo> pageInfo = nursingLevelService.selectByPage( pageNum, pageSize, name, status);

        return ResponseResult.success(pageInfo);


    }

    @DeleteMapping ("/delete/{id}")
    @ApiOperation("根据id删除护理等级")
    public ResponseResult deleteById(@PathVariable Long id){

        nursingLevelService.deleteNursingLevel(id);

        return ResponseResult.success();

    }

    @PutMapping("/{id}/status/{status}")
    @ApiOperation("启用、禁用护理等级")
    public ResponseResult updateStatus(@PathVariable("id") Long id, @PathVariable("status") Integer status){

        nursingLevelService.updateStatus(id,status);

        return ResponseResult.success();

    }

    @PostMapping("/insert")
    @ApiOperation("添加护理等级")
    public ResponseResult addNursingLevel(@RequestBody NursingLevelDto nursingLevelDto){

        nursingLevelService.addNursingLevel(nursingLevelDto);

        return ResponseResult.success();

    }

    @PutMapping("/update")
    @ApiOperation("修改护理等级")
    public ResponseResult updateNursingLevel(@RequestBody NursingLevelDto nursingLevelDto){

        nursingLevelService.updateNursingLevel(nursingLevelDto);

        return ResponseResult.success();

    }


}
